from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from ubcAccess.models import *

admin.site.unregister(User)

class UserProfileInline(admin.StackedInline):
    fieldsets = [
        ('Personal Info',{'fields':['phone_mobile','phone_home','student_number']}),
        ('Address',{'fields':['address','city','postal_code']}),
        ('Membership',{'fields':['member_type','jericho_member_type','join_date','expiry_date','active','suspended']}),
        ('Access',{'fields':['hid_number','access_clubroom', 'access_fixit', 'access_multiskiff', 'access_windsurfl1', 'access_windsurfl2', 'access_kayak'],'classes': ['collapse']})
    ]
    model = UserProfile
    fk_name = 'user'
    max_num = 1

class UserQualificationInline(admin.TabularInline):
    model = UserQualification
    fk_name = 'user'
    extra = 1

class UserMemoInline(admin.TabularInline):
    model = UserMemo
    fk_name = 'user'
    extra = 1

class UserCreditMemoInline(admin.TabularInline):
    model = UserCreditMemo
    fk_name = 'user'
    extra = 1

class UserProfileAdmin(UserAdmin):
    list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff', 'is_active')
    inlines = [UserProfileInline, UserQualificationInline, UserCreditMemoInline, UserMemoInline]

admin.site.register(User, UserProfileAdmin)

#class ClubMemberAdmin(admin.ModelAdmin):
#    fieldsets = [
#       ('Profile',{'fields':['first_name','last_name','email_address','phone_mobile','phone_home','student_number']}),
#        ('Address',{'fields':['address','city','postal_code']}),
#        ('Membership',{'fields':['member_type','jericho_member_type','join_date','expiry_date','active','suspended']}),
#        ('Qualifications',{'fields':['qualifications_monohull', 'qualifications_multihull', 'qualifications_windsurf', 'qualifications_kayak']}),
#        ('Access',{'fields':['hid_number','access_clubroom', 'access_fixit', 'access_multiskiff', 'access_windsurfl1', 'access_windsurfl2', 'access_kayak'],'classes': ['collapse']})
#    ]
#    list_display = ['first_name', 'last_name', 'member_type','active','suspended']
#    list_display_links = ['first_name', 'last_name']
#    list_filter = ['member_type','active','suspended']
#    search_fields = ['first_name','last_name']
# admin.site.register(ClubMember,ClubMemberAdmin)

